package org.jeecg.modules.nikeProject.controller;

import javax.servlet.http.HttpServletRequest;

import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.util.JwtUtil;
import org.jeecg.modules.nikeProject.entity.SportsProjectReview;
import org.jeecg.modules.nikeProject.entity.vo.SubmitReveiwVO;
import org.jeecg.modules.nikeProject.entity.vo.UpdateReviewVO;
import org.jeecg.modules.nikeProject.entity.vo.QueryProjectReviewVO;
import org.jeecg.modules.nikeProject.service.ISportsProjectReviewService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.List;

/**
 * @Description: 案例评审表
 * @Author: jeecg-boot
 * @Date:   2024-12-20
 * @Version: V1.0
 */
@Slf4j
@Api(tags="208-案例评审表")
@RestController
@RequestMapping("/projectReview")
public class SportsProjectReviewController extends JeecgController<SportsProjectReview, ISportsProjectReviewService> {
	@Autowired
	private ISportsProjectReviewService sportsProjectReviewService;
	
	/**
	 * 分页列表查询
	 *
	 * @param reviewVO
	 * @param req
	 * @return
	 */
	@AutoLog(value = "案例评审表-分页列表查询")
	@ApiOperation(value="案例评审表-分页列表查询", notes="案例评审表-分页列表查询")
	@PostMapping(value = "/list")
	public Result<?> queryPageList(@RequestBody QueryProjectReviewVO reviewVO,
									HttpServletRequest req) {
		String username = JwtUtil.getUserNameByToken(req);
		reviewVO.setUsername(username);
		Page<SportsProjectReview> page = new Page<>(reviewVO.getPageNo(), reviewVO.getPageSize());
		return sportsProjectReviewService.getJudgeReviewList(page, reviewVO);
	}
	
	/**
	 * 更新评审对案例的打分信息
	 * @param ids  案例评审ids
	 * @return
	 */
	@AutoLog(value = "提交评审打分")
	@ApiOperation(value="提交评审打分", notes="提交评审打分")
	@PostMapping(value = "/submitProjectReview")
	public Result<?> submitProjectReview(@RequestParam List<String> ids,
										 HttpServletRequest request) {
		String username = JwtUtil.getUserNameByToken(request);
		return sportsProjectReviewService.submitProjectReview(ids, username);
	}

	@AutoLog(value = "保存评审对案例的打分信息")
	@ApiOperation(value="保存评审对案例的打分信息", notes="保存评审对案例的打分信息")
	@PostMapping(value = "/saveProjectReview")
	public Result<?> saveProjectReview(@RequestBody UpdateReviewVO updateReviewVO,
									   HttpServletRequest request){
		String username = JwtUtil.getUserNameByToken(request);
		return sportsProjectReviewService.updateProjectReview(updateReviewVO, username);
	}

	@AutoLog(value = "保存国际行案例评审打分信息")
	@ApiOperation(value="保存国际行案例评审打分信息", notes="保存国际行案例评审打分信息")
	@PostMapping(value = "/saveITReview")
	public Result<?> saveITReview(@RequestBody UpdateReviewVO updateReviewVO,
									   HttpServletRequest request){
		String username = JwtUtil.getUserNameByToken(request);
		return sportsProjectReviewService.saveInternationalTravelReview(updateReviewVO, username);
	}

	@AutoLog(value = "提交国际行数据")
	@ApiOperation(value="提交国际行数据", notes="提交国际行数据")
	@PostMapping(value = "/submitITReview")
	public Result<?> submitITReview(@RequestParam List<String> ids,
												   HttpServletRequest request){
		String username = JwtUtil.getUserNameByToken(request);
		return sportsProjectReviewService.submitInternationalTravelReview(ids, username);
	}

}
